package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.crowdsource.CityConfigFormBean;
import com.info.zhiduoduo.admin.model.formbean.crowdsource.CityConfigQuotaFormBean;
import com.info.zhiduoduo.admin.model.formbean.crowdsource.CompanyQuotaFormBean;
import com.info.zhiduoduo.admin.model.formbean.crowdsource.MakerQuotaFormBean;
import com.info.zhiduoduo.admin.model.formbean.crowdsource.listCityConfigsFormBean;
import com.info.zhiduoduo.admin.service.QuotaService;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.quota.CityConfigDto;
import com.info.zhiduoduo.repository.dto.quota.CompanyQuotaDto;
import com.info.zhiduoduo.repository.dto.quota.MakerQuotaDto;

import com.info.zhiduoduo.repository.entity.company.Company;
import com.info.zhiduoduo.repository.entity.maker.MakerStudio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/quota")
public class QuotaController {

	@Autowired
	QuotaService quotaService;

	@ApiOperation("新建开户地城市配置")
	@PostMapping("/addCityConfig")
	public SmartResult addCityConfig(@RequestBody BaseSimpleFormBean<CityConfigFormBean> formBean) {
		return quotaService.addCityConfig(formBean);
	}

	@ApiOperation("获取城市配置列表")
	@PostMapping("/listCityConfigs")
	public SmartResult<CityConfigDto> listCityConfigs(@RequestBody BaseSimpleFormBean<listCityConfigsFormBean> formBean) {
		return quotaService.listCityConfigs(formBean);
	}

	@ApiOperation("编辑开户地城市配置（不能新建）、智众包项目限额、 项目限额")
	@PostMapping("/editCityConfigQuota")
	public SmartResult editCityConfigQuota(@RequestBody BaseSimpleFormBean<CityConfigQuotaFormBean> formBean) {
		return quotaService.editCityConfigQuota(formBean);
	}

	@ApiOperation("获取创客限额")
	@PostMapping("/getMakerQuota")
	public SmartResult<MakerQuotaDto> getMakerQuota(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return quotaService.getMakerQuota(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE,name = "编辑创客限额",entities = @LogEntity(entity = MakerStudio.class,parameters =
	@LogParameter(fields = "userid",parameters = "formBean.reqdata.userid")))
	@ApiOperation("编辑创客限额")
	@PostMapping("/editMakerQuota")
	public SmartResult editMakerQuota(@RequestBody BaseSimpleFormBean<MakerQuotaFormBean> formBean) {
		return quotaService.editMakerQuota(formBean);
	}

	@ApiOperation("获取企业限额")
	@PostMapping("/getCompanyQuota")
	public SmartResult<CompanyQuotaDto> getCompanyQuota(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return quotaService.getCompanyQuota(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE,name = "编辑企业限额",entities = @LogEntity(entity = Company.class,parameters =
	@LogParameter(fields = "compid",parameters = "formBean.reqdata.compid")))
	@ApiOperation("编辑企业限额")
	@PostMapping("/editCompanyQuota")
	public SmartResult editCompanyQuota(@RequestBody BaseSimpleFormBean<CompanyQuotaFormBean> formBean) {
		return quotaService.editCompanyQuota(formBean);
	}
	
}
